// ----------------------------------------------------------------------------
/**
 * @file    chatWindow.h
 *
 * @brief   Header file for chatWindow.cpp
 *
 * The chatWindow class allows the user to interact with their friends by chatting with them by text.
 *
 * @author  Siddharth Sathyam <ssathy2@gmail.com>
 * @author  Alan Ruvalcaba <aruval3@gmail.com>
 * @author  Patrick LaMontagna <plamontagna@gmail.com
 *
 * @version 1.0
 *
 * @date    November 24th, 2011
 *
 */
// ----------------------------------------------------------------------------

#ifndef CHATWINDOW_H
#define CHATWINDOW_H

#include <QDialog>
#include "client.h"
#include <QDesktopServices>
#include <QDir>
#include "QKeyEvent"
namespace Ui {
    class chatWindow;
}

/**
 * @class   chatWindow
 *
 * @brief   The chatWindow helper methods
 *
 */

class chatWindow : public QDialog
{
    Q_OBJECT

public:

    /// Constructor method for chatWindow
    explicit chatWindow(QWidget *parent = 0);

    /// Deconstructor for chatWindow
    ~chatWindow();

    /**
    * @brief Method that sets the from user attribute
    *
    * @param username The username of the from user
    */

    void setfromUser(QString);

    /**
    * @brief Method that sets the to user attribute
    *
    * @param username The username of the to user
    */

    void setToUser(QString);

    /**
    * @brief Method that gets the to user information
    * @param ToUser The username receiving the message
    * @return The to user of the message
    */

    QString getToUser();

    /**
    * @brief Method that gets the from user information
    * @return The to username
    */

    QString getFromUser();

    /**
    * @brief Method that gets the operating system information from the user
    * @return Operating System type
    */

    QString getOsType();

    /**
    * @brief Method that receives the message
    *
    * @param message The chat message
    * @param fromUser The from user
    * @param time The time of the message
    */
    void receiveMessage(QString,QString,QString);

private slots:

    /**
    * @brief Slot that determines if the user has clicked the send button
    */
    void on_sendButton_clicked();

private:
    Ui::chatWindow *ui;

    /// toUser variable
    QString toUser;

    /// fromUser variable
    QString fromUser;

    /**
    * @brief Method that saves chat conversations to a text file
    *
    * @param name The name of the file to save
    * @param message The conversation message
    */

    void OutPutChat(QString,QString);

    bool eventFilter(QObject *ob, QEvent *e);

signals:

    /**
    * @brief Signal that sends the message
    *
    * @param fromUser The from user of the message
    * @param toUser The to user of the message
    * @param message The chat message
    * @param time The time of the message being sent
    */

    void messageSent(QString,QString,QString,QString);

};

#endif // CHATWINDOW_H
